using System;
using UnityEngine;

namespace PKGames.Audio
{
	public class AudioSourceData
	{
		private string _id;

		private AudioSource _audioSource;

		private Action<string> _endSoundNotification;

		public string Id => _id;

		public AudioSourceData(string id, AudioSource audioSource, Action<string> endSoundNotification)
		{
			_id = id;
			_audioSource = audioSource;
			_endSoundNotification = endSoundNotification;
		}

		public bool IsPlaying()
		{
			if (_audioSource != null && _audioSource.clip != null)
			{
				return _audioSource.isPlaying;
			}
			return false;
		}

		public void StopAudio()
		{
			_audioSource.Stop();
		}

		public void EndSoundNotification()
		{
			if (_endSoundNotification != null)
			{
				_endSoundNotification(_id);
			}
		}
	}
}
